#ifndef _POSTALCODE_H_
#define _POSTALCODE_H_

#include "City.h"

/**
 * Implementation of the class PostalCode.
 * A postal code is defined by a reference whose range is from 0 to 9999,
 * an indicative whose range is from 0 to 999, and a city.
 */
class PostalCode
{

public:
    PostalCode();
    PostalCode(unsigned short reference, unsigned short indicative, City & city);
    virtual ~PostalCode();

    // Reference
    unsigned short getReference() const;
    void setReference(unsigned short reference);

    // Indicative
    unsigned short getIndicative() const;
    void setIndicative(unsigned short indicative);

    // City
    City *getCity() const;
    void setCity(City &city);

    // I/O
    string printPostalCode();
    void newAddress(PostalCode & postalCode);

    // Exception treatment class
    class InvalidPostalCode {
    public:
        InvalidPostalCode ();
        void printError(ostream & os) {
            os << "Invalid Postal Code: \n\treference from 0 to 9999\n\tindicative"
                    " from 0 to 999" << endl;
        }
    };

private:
    unsigned short reference;
    unsigned short indicative;
    City *city;

};
#endif // _POSTALCODE_H_
